﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using ChBusiness.Wsbs;
using ChBusiness;
using System.Drawing;
using ChBusiness.Menu;


public partial class Wsbs_submit : System.Web.UI.Page
{
    private SerialInstance cInstance = new SerialInstance();
    private ShenBaoSubmit cSubmit = new ShenBaoSubmit();
    private string strFlag = "0";
    private string strDangQianRenWu = "当前任务";
    public string strZhuce;
    protected void Page_Load(object sender, EventArgs e)
    {    
        if (!IsPostBack)
        {
            strZhuce = string.Empty;
            try
            {
                if (!string.IsNullOrEmpty(Session["LoginUserName"].ToString()))
                {
                    strZhuce = "欢迎：" + Session["LoginUserName"].ToString() + "  " + "<a href='javascript:LoginOut()'  class='top_exit'>退出<a>";
                    //lb_Register.Text = "欢迎：" + Session["LoginUserName"].ToString()+"<a href=''>退出</a>";
                }
                else
                {
                    strZhuce = " <a class='top-right-title' href='/isp/isp/projects/sbsm/bsdt/register.jsp'>注册</a>";
                }
            }
            catch
            {
                strZhuce = " <a class='top-right-title' href='/isp/isp/projects/sbsm/bsdt/register.jsp'>注册</a>";
            }
        }
    }

  
    /// <summary>
    /// 加载导航菜单--first
    /// </summary>
    /// <returns></returns>
    protected string GetContent()
    {
        string strHtml = string.Empty;
        if (Session["UserId"] == null)
            strHtml = GetContentByFlow();
        else
        {
            if (strFlag == "0")
            {
                string strParentName = string.IsNullOrEmpty(Request["ParentName"]) ? "导航申报" : Request["ParentName"];
                strHtml = GetLeftNavgation(strParentName);
            }
            else
            {
                strHtml = GetContentByFlow();
            }
        }
        return strHtml;
    }

    /// <summary>
    /// 加载导航申报左边树菜单(导航内容) three
    /// </summary>
    /// <returns></returns>
    protected string GetLeftNavgation(string strParentMenu)
    {
        ClsMenuOperation menuOperation = new ClsMenuOperation();
        DataTable dtMenu = menuOperation.GetChildMenus(strParentMenu);

        string strHtml = string.Empty;

        int nIndex = 0;
        foreach (DataRow drTemp in dtMenu.Rows)
        {
            string strMenuTitle = drTemp["menu_title"].ToString();
            string strMenuUrl = drTemp["menu_url"].ToString();
            nIndex++;

            strMenuUrl = strMenuUrl.Replace("~", HttpContext.Current.Request.ApplicationPath);

            strHtml += string.Format("<div title='{0}'  style='padding: 20px;'> <iframe id='iframeConfig' scrolling='no' frameborder='0' src='{1}' style='width:1000px; height: 100%;'></iframe></div>", strMenuTitle, strMenuUrl.Replace("submit.aspx","submitSrc.aspx"));

        }
        strHtml += "</div>";

        return strHtml;
    }


    /// <summary>
    /// 加载导航菜单-second
    /// </summary>
    /// <returns></returns>
    /// <!--addby zhongjian 20091102-->
    protected string GetContentByFlow()
    {
        if (ViewState["strFlowName"] == null)
        {
            return "";
        }
        string strRequestFlowName = ViewState["strFlowName"].ToString();
        string strMenuType = string.Empty;
        string strHtml = string.Format("<div class='left_box_bar' style='cursor: pointer; margin-left: 0px;' id='divMenu'>{0}</div><ul class='left_ul' id='ulMenu1' style='margin-left:20px;'>", "网上办事");

        //获取菜单权限
        ClsMenuOperation menuOperation = new ClsMenuOperation();
        DataTable dtMenu = menuOperation.GetChildMenus("网上办事");

        //获取菜单权限
        WebWork cWorks = new WebWork();
        DataTable dtMenuRight = cWorks.GetChildMenuRight(strRequestFlowName);
        string strFlowName = Server.UrlEncode(strRequestFlowName);
        foreach (DataRow drTemp in dtMenu.Rows)
        {
            string strMenuTitle = drTemp["menu_title"].ToString();
            string strMenuUrl = drTemp["menu_url"].ToString();

            int nOrder = Convert.ToInt32(drTemp["ORDER_FIELD"].ToString());
            nOrder = nOrder - 1;

            int nIndex = 0;
            dtMenuRight.DefaultView.RowFilter = string.Format("menu_name='{0}'", strMenuTitle);
            if (dtMenuRight.DefaultView.Count > 0)
            {
                //添加流程别名参数
                string strFlowType = Server.UrlEncode(dtMenuRight.DefaultView[0].Row["flowtype"].ToString());
                //判断是否有权限查看               
                strMenuUrl = strMenuUrl.Replace("~", HttpContext.Current.Request.ApplicationPath);

                nIndex++;
                string strClass = "left_ul";
                if (nIndex == dtMenu.Rows.Count)
                {
                    strClass = "on";
                }

                //从网上办事页面跳转到相关页面
                strHtml += string.Format("<li id=\"menu{0}\" class=\"{5}\"><a href=\"{4}&flowname={2}&flowtype={3}\" onclick=\"setTab({0})\" id='a{0}'>{1}</a></li>",
                    nOrder, strMenuTitle, strFlowName, strFlowType, strMenuUrl, strClass);
            }
        }

        return strHtml;
    }
}
